<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {

            $table->increments('id');

            $table->string('name')->nullable()->comment('姓名');
            $table->string('email')->nullable()->comment('email');
            $table->integer('pid')->default(0)->comment('师父id');
            $table->integer('fid')->default(0)->comment('师公id');
            $table->char('phone', 11)->comment('手机号');
            $table->string('password')->comment('密码');
            $table->char('extend_code', 10)->comment('用户推广码');
            $table->enum('level', ['1', '2', '3'])->default('2')->comment('用户等级 1 优 2 中 3 差');
            $table->ipAddress('reg_ip')->comment('注册ip');
            $table->ipAddress('last_login_ip')->nullable()->comment('上次登录ip');
            $table->timestamp('last_login_time')->nullable()->comment('上次登录时间');
            $table->enum('is_black', ['0', '1'])->default('0')->comment('是否拉黑 0 否 1 是');
            $table->text('remark')->nullable()->comment('备注');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
